package com.dbsop.config;

import com.dbsop.EsClient;
import com.dbsop.EsOperation;
import com.dbsop.mapper.ESBaseMapper;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Configuration
public class EsBeanLoad {

    @Bean
    @Order(Integer.MIN_VALUE)
    @ConfigurationProperties(prefix = "elasticsearch")
    public EsClientConfig getEsClientConfig(){
        return new EsClientConfig();
    }


    @Bean
    @Order(Integer.MIN_VALUE)
    public EsClient initEsClient(EsClientConfig esClientConfig,
                                 List<ESBaseMapper> esBaseMappers){
        EsOperation.run(esClientConfig,esBaseMappers);
        return EsClient.getEsClient();
    }
}
